﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace LastfmNet.Models
{
    public class Location : LastfmModelBase
    {
        public Location()
        {
            this.City = string.Empty;
            this.Country = string.Empty;
            this.Street = string.Empty;
            this.PostalCode = 0;
            this.GeoPoint = new GeoPoint();
        }

        public Location(XmlNode locationNode)
        : this()
        {
            if (locationNode == null) return;
            this.InitializeFromXmlNode(locationNode);
        }

        public override void InitializeFromXmlNode(XmlNode node)
        {
            if (node == null) return;
            this.City = node.GetChildValue("city");
            this.Country = node.GetChildValue("country");
            this.Street = node.GetChildValue("street");
            this.PostalCode = node.GetChildValue("postalcode").ToInteger();
            this.GeoPoint = new GeoPoint(node.GetChild("geo:point"));
        }

        public string City { get; set; }

        public string Country { get; set; }

        public string Street { get; set; }

        public int PostalCode { get; set; }

        public GeoPoint GeoPoint { get; set; }
    }
}
